package com.migraine.mapper;

import com.migraine.model.Users;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UsersMapper {
    int deleteByPrimaryKey(String uid);


    int insert(Users record);

    int insertSelective(Users record);

    @Select("select * from users where UID=#{id}")
    Users selectByPrimaryKey(int uid);

    int updateByPrimaryKeySelective(Users record);

    int updateByPrimaryKey(Users record);

    @Select("select * from users where username = #{name}")
    Users getUsersByName(String name);

    @Select("select * from users")
    List<Users> getAllUsers();

    @Insert("insert into users(username,password) values (#{username},#{password})")
    boolean insertUsers(String username, String password);

    // 根据本命name1 将用户名修改为name2
    @Update("update users set username=#{name2} where username=#{name1}")
    boolean updateNameByName(String name1, String name2);

    //将名字为name的用户的密码改为pwd
    @Update("update users set password=#{pwd} where username=#{name}")
    boolean updatePwdByName(String name, String pwd);

    // 修改头像
    @Update("update users set userimage=#{img} where UID=#{id}")
    boolean updateImageById(int id, String img);

    // 根据名字删除用户
    @Delete("delete from users where username=#{username}")
    boolean deleteByName(String username);

    @Update("update users set userimage=#{photo} where username=#{name}")
    boolean setPhoto(String name,String photo);
}